# !/usr/bin/env python
#-*- coding:utf-8 -*-
import requests
import re
import csv
cid=input('请输入数字：大胸2，翘臀6，黑丝7，美腿3，颜值4，大杂烩5：')
name={'2':'大胸','3':'美腿','4':'颜值','5':'大杂烩','6':'翘臀','7':'黑丝'}
for num in range(1,1000):
    img_url_list=[]
    html_url='https://www.dbmeinv.com/dbgroup/show.htm?cid={}&pager_offset={}'.format(cid,num)
    response = requests.get(html_url)
    if response.status_code==404:
        print("第{}个页面不存在".format(num))
        continue
    html = (response.text)
    page_url_info = re.findall(r'a href="(.*?)" class="link" target="', html)
    for page_url in page_url_info:
        response = requests.get(page_url)
        if response.status_code != 200:
            print("加载错误")
            continue
        html = (response.text)
        img_url_info = re.findall(r'img src="(.*.jpg)"', html)
        for img_url in img_url_info:
                if img_url not in img_url_list:
                    img_url_list.append(img_url)
                    text.write(img_url + '\r\n')
                    print("爬取第{}个页面".format(num))